﻿using Ensemble_Windows.Core;
using SharpDX.DirectWrite;

namespace Ensemble_Windows.UI.Text
{
    /// <summary>
    ///     文字帮助类
    /// </summary>
    public sealed class TextHelper
    {
        /// <summary>
        ///     获取Format
        /// </summary>
        /// <param name="factoryDWrite">一般在Initialize传值</param>
        /// <returns></returns>
        public static TextFormat GetFormat(Factory factoryDWrite)
        {
            var textFormat = new TextFormat(factoryDWrite, "宋体", 12)
            {
                TextAlignment = TextAlignment.Center,
                ParagraphAlignment = ParagraphAlignment.Center
            };
            return textFormat;
        }

        /// <summary>
        ///     获取Layout
        /// </summary>
        /// <param name="factoryDWrite">
        ///     <see cref="Factory" />
        /// </param>
        /// <param name="text">文字</param>
        /// <param name="configuration">配置</param>
        /// <param name="format">
        ///     <see cref="TextFormat" />
        /// </param>
        /// <returns></returns>
        public static TextLayout GetLayout(Factory factoryDWrite, string text, Configuration configuration,
            TextFormat format)
        {
            var textLayout = new TextLayout(factoryDWrite, text, format, configuration.Width, configuration.Height);
            return textLayout;
        }
    }
}